package com.zsinfo.guoss.supplier.activity;

import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.example.netcenter.Event.Response;
import com.example.netcenter.RetrofitBuilder;
import com.example.netcenter.Url.ConstantsCode;
import com.example.netcenter.bean.DescBean;
import com.example.netcenter.bean.ResultsData;
import com.zsinfo.guoss.supplier.R;
import com.zsinfo.guoss.supplier.base.BaseActivity;
import com.zsinfo.guoss.supplier.utils.SharedPreferencesUtil;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by lixl on 2018/12/5.
 * <p>
 * desc: 退款须知
 */
public class MarginNoticeActivity extends BaseActivity {

    private int status;
    private int type;
    private int totalMoney;
    private int canUseMoney;

    @Override
    protected int getContentLayoutRes() {
        return R.layout.activity_margin_notice;
    }

    @BindView(R.id.desc)
    TextView desc;
    @Override
    protected void initView() {
        setTitle("条款须知");
        setBackAndLeftTitle("").setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        status = getIntent().getExtras().getInt("status");
        if (status == 1) {
            type = getIntent().getIntExtra("type", 1);
            totalMoney = getIntent().getIntExtra("totalMoney", 0);
            canUseMoney = getIntent().getIntExtra("canUseMoney", 0);
        }
    }

    @OnClick({R.id.btn_return_margin})
    void MyClick(View view) {
        if (status == 1) {
            Intent intent = new Intent(MarginNoticeActivity.this, MarginToPayActivity.class);
            intent.putExtra("type", type);  //type，保证金类型
            intent.putExtra("totalMoney", totalMoney); //总金额
            intent.putExtra("canUseMoney", canUseMoney);//可报价金额
            startActivity(intent);
        }
        finish();
    }

    @Override
    protected void initNetData() {
        GetNetCenter().GetNetCenter(this, RetrofitBuilder.CreateApi().SUPPLIER_TERMS(ConstantsCode.gss_desc, SharedPreferencesUtil.getWebsiteNode()+"#GYSXY-DESC"), new Response() {
            @Override
            public void OK(Object data) {

                ResultsData<DescBean> resultsData = (ResultsData<DescBean>) data;
                DescBean descBean = resultsData.getData();
                desc.setText(descBean.getDesc());
            }

            @Override
            public void Fail(Throwable e) {

            }

            @Override
            public void complete() {

            }
        });
    }

    @Override
    protected void customDestroy() {

    }
}
